project  (syncctl)

cmake_minimum_required (VERSION 2.6.2)
set (CMAKE_VERBOSE_MAKEFILE 1)
if (COMMAND cmake_policy)
    cmake_policy(SET CMP0003 NEW)
endif (COMMAND cmake_policy)

SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR})

find_package(ODBC REQUIRED)

SET(BISON_GENERATE_DEFINES TRUE)

find_package(BISON REQUIRED)
find_package(FLEX REQUIRED)
find_package(LibArchive REQUIRED)

bison_target(nodesconf_parser nodesconf.y ${CMAKE_CURRENT_BINARY_DIR}/nodesconf.tab.c COMPILE_FLAGS "-p nodesconf")
flex_target(nodesconf_scanner nodesconf.lex ${CMAKE_CURRENT_BINARY_DIR}/nodesconf.yy.c COMPILE_FLAGS "-P nodesconf")
add_flex_bison_dependency(nodesconf_scanner nodesconf_parser)
add_library(nodesconf ${BISON_nodesconf_parser_OUTPUTS} ${FLEX_nodesconf_scanner_OUTPUTS})

bison_target(syncconf_parser syncconf.y ${CMAKE_CURRENT_BINARY_DIR}/syncconf.tab.c COMPILE_FLAGS "-p syncconf")
flex_target(syncconf_scanner syncconf.lex ${CMAKE_CURRENT_BINARY_DIR}/syncconf.yy.c COMPILE_FLAGS "-P syncconf")
add_flex_bison_dependency(syncconf_scanner syncconf_parser)
add_library(syncconf STATIC ${BISON_syncconf_parser_OUTPUTS} ${FLEX_syncconf_scanner_OUTPUTS})

bison_target(packetinfo_parser packetinfo.y ${CMAKE_CURRENT_BINARY_DIR}/packetinfo.tab.c COMPILE_FLAGS "-p packetinfo")
flex_target(packetinfo_scanner packetinfo.lex ${CMAKE_CURRENT_BINARY_DIR}/packetinfo.yy.c COMPILE_FLAGS "-P packetinfo")
add_flex_bison_dependency(syncconf_scanner syncconf_parser)
add_library(packetinfo ${BISON_packetinfo_parser_OUTPUTS} ${FLEX_packetinfo_scanner_OUTPUTS})

include_directories(${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR})
add_executable (syncctl syncctl.c connect.c system.c node.c table.c data.c prepared.c updated.c packet.c)
target_link_libraries (syncctl ${ODBC_LIBRARIES} syncconf packetinfo nodesconf)
